﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<CallMVC.Models.LoginModel>" %>



<asp:Content ID="calculationTitle" ContentPlaceHolderID="Title1" runat="server">
          <%
      DBManager.Customer cust = ViewBag.Customer;
  
       %>
   <a href="<%: Url.Action("Calculation", "Home", new { customerId = cust.CustomerID })%>"><img src="/CalcApp/images/<%= cust.LogoLink %>"   /></a>
</asp:Content>

<asp:Content ID="calculationContent" ContentPlaceHolderID="MainContent" runat="server">
    
    <% using (Html.BeginForm()) {
           DBManager.Customer cust = ViewBag.Customer;
           
           DBManager.Calculation calculation = (DBManager.Calculation)this.ViewBag.Calculation;
          
            %>
        <%: Html.ValidationSummary() %>

        <%  System.Collections.Generic.List<DBManager.OrderControl> orderControl = (System.Collections.Generic.List<DBManager.OrderControl>)ViewBag.Orders;
           
            DBManager.OrderControl latestOrder = ( DBManager.OrderControl)ViewBag.LatestOrder;

            string data_filter_text = "Filter items";

            if (cust.TextFilterItems != null)
                data_filter_text = cust.TextFilterItems;
         %>

            <ul data-role="listview" data-inset="true" data-filter-placeholder="<%=data_filter_text %>">
            <li data-role="listview"><h3><%: Html.Label(calculation.CaculationName) %></h3></li>
            </ul>

            <ul data-role="listview" data-filter="false">
                

<%     
            bool Access = true;
            if (User.Identity.IsAuthenticated)
            {
                DBManager.User user = DBManager.DBManager.Instance.GetUser(User.Identity.Name);

                Access = user.CanAccess(calculation);
            }


            if (Access == false)
            {                    
%>
<br />
  <center>Access denied.</center>

 <% }
            else
            { %>
 <li>
                <%:       
                Html.ActionLink(calculation.TextNewCalc, "CalcInput", new { calculationId = calculation.CalculationID})
                %>
                </li>
                
                <li>
                <%:       
                Html.ActionLink(calculation.TextLatestCalc, "CalcInput", new { calculationId = calculation.CalculationID, orderId = latestOrder.ID.ToString() })
                %>
                </li>
                <% if (orderControl.Count > 0)
                   {  %>
                <li>
                <%:       
                Html.ActionLink(calculation.TextPickList, "SaveOrderCtrl", new { calculationId = calculation.CalculationID })
                %>

                
                </li>
                <% } %>

                <% } %>
            </ul>
        
    
    <br />

        <% } %>
    
</asp:Content>